using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Resources;
using System.Reflection;
using Microsoft.Samples.SqlServer.HRWebService;
using System.Globalization;
using System.Net;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;
using System.Text;
using System.Data.SqlClient;
using System.Runtime.Serialization;


/*=====================================================================

  File:      Main.cs
  Summary:   User interface for HR Resume application 
  Date:	     March 9, 2004

---------------------------------------------------------------------

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= */

namespace Microsoft.Samples.SqlServer
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class MainForm : System.Windows.Forms.Form
	{
		String stylesheet = "";

		private String tempFileName = Path.ChangeExtension(Path.GetTempFileName(), "htm");

		private String allOfThesePhrase;

		private String anyOfThesePhrase;

		private String namePhrase;

		private String modifiedDatePhrase;

		private String noErrorMessage;

		private System.Windows.Forms.Panel panel1;

		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem fileMenuItem;

		private System.Windows.Forms.MenuItem editMenuItem;

		private System.Windows.Forms.MenuItem viewMenuItem;

		private System.Windows.Forms.MenuItem helpMenuItem;

		private System.Windows.Forms.MenuItem exitMenuItem;

		private System.Windows.Forms.PictureBox pictureBox1;

		private System.Windows.Forms.TabPage mainTabPage;

		private System.Windows.Forms.TabPage resumeTabPage;

		private System.Windows.Forms.TabControl mainTabControl;

		private System.Windows.Forms.PictureBox pictureBox2;

		private System.Windows.Forms.Label headlineLabel;

		private System.Windows.Forms.Button unassignedOpenPositionsButton;

		private System.Windows.Forms.Button pendingInterviewsButton;

		private System.Windows.Forms.Button assignedOpenPositionsButton;

		private System.Windows.Forms.Label dataRangeLabel;

		private System.Windows.Forms.Label candidateNameLabel;
		private System.Windows.Forms.TextBox textSearchTextBox;
		private System.Windows.Forms.TextBox dateToTextBox;
		private System.Windows.Forms.TextBox dateFromTextBox;

		private System.Windows.Forms.TextBox candidateNameTextBox;

		private System.Windows.Forms.Label textSearchLabel;

		private System.Windows.Forms.WebBrowser resumeDetailsWebBrowser;

		private System.Windows.Forms.DataGridView summaryDataGridView2;

		private System.Windows.Forms.ComboBox searchModeComboBox;

		private System.Windows.Forms.Button searchButton;

		private System.Windows.Forms.Label errorLabel;

		private System.Windows.Forms.Label introLabel;
		private System.Windows.Forms.PictureBox newsPictureBox;
		private System.Windows.Forms.MainMenu standardMainMenu;
		private System.Windows.Forms.MenuItem fileMenuItem1;
		private System.Windows.Forms.MenuItem newMenuItem;
		private System.Windows.Forms.MenuItem openMenuItem;
		private System.Windows.Forms.MenuItem separatorMenuItem;
		private System.Windows.Forms.MenuItem saveMenuItem;
		private System.Windows.Forms.MenuItem saveAsMenuItem;
		private System.Windows.Forms.MenuItem separatorMenuItem1;
		private System.Windows.Forms.MenuItem printMenuItem;
		private System.Windows.Forms.MenuItem printPreviewMenuItem;
		private System.Windows.Forms.MenuItem separatorMenuItem2;
		private System.Windows.Forms.MenuItem exitMenuItem1;
		private System.Windows.Forms.MenuItem editMenuItem1;
		private System.Windows.Forms.MenuItem undoMenuItem;
		private System.Windows.Forms.MenuItem redoMenuItem;
		private System.Windows.Forms.MenuItem separatorMenuItem3;
		private System.Windows.Forms.MenuItem cutMenuItem;
		private System.Windows.Forms.MenuItem copyMenuItem;
		private System.Windows.Forms.MenuItem pasteMenuItem;
		private System.Windows.Forms.MenuItem separatorMenuItem4;
		private System.Windows.Forms.MenuItem selectAllMenuItem;
		private System.Windows.Forms.MenuItem helpMenuItem1;
		private System.Windows.Forms.MenuItem contentsMenuItem;
		private System.Windows.Forms.MenuItem indexMenuItem;
		private System.Windows.Forms.MenuItem searchMenuItem;

		private System.Windows.Forms.MenuItem separatorMenuItem5;

		private System.Windows.Forms.MenuItem aboutMenuItem;

		private System.Windows.Forms.Label newsLabel;

		private System.Windows.Forms.ComboBox languageComboBox;

		private System.Windows.Forms.Button ToCalendarButton;

		private System.Windows.Forms.Button FromCalendarButton;
		private BindingNavigator summaryBindingNavigator;
		private ToolStripLabel dataNavigatorCountItem;
        private ToolStripButton dataNavigatorMoveFirstItem;
        private ToolStripButton dataNavigatorMovePreviousItem;
        private ToolStripSeparator dataNavigatorSeparator;
        private ToolStripTextBox dataNavigatorPositionItem;
        private ToolStripSeparator dataNavigatorSeparator1;
        private ToolStripButton dataNavigatorMoveNextItem;
        private ToolStripButton dataNavigatorMoveLastItem;
        private ToolStripSeparator dataNavigatorSeparator2;
        private DataGridView summaryDataGridView;
        private BindingSource summaryBindingSource;

        /// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		public MainForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			// Handler for when the user clicks on a row of the data grid.
			// It will display the resume for the selected candidate.
			summaryDataGridView.RowEnter += new DataGridViewCellEventHandler(
				summaryDataGridView_RowEnter);

			// Access localizable text and images from the resource file for the
			// sample.
			ResourceManager lrm = new ResourceManager(
				"Microsoft.Samples.SqlServer.LocalizedResources",
				Assembly.GetExecutingAssembly());
			ResourceManager nlrm = new ResourceManager("Microsoft.Samples.SqlServer.NonLocalizedResources",
				Assembly.GetExecutingAssembly());

			allOfThesePhrase = lrm.GetString("AllOfThese");
			anyOfThesePhrase = lrm.GetString("AnyOfThese");
			searchModeComboBox.Items.Add(anyOfThesePhrase);
			searchModeComboBox.Items.Add(allOfThesePhrase);
			searchModeComboBox.SelectedItem = allOfThesePhrase;
			stylesheet = lrm.GetString("ResumeXslt");
			newsPictureBox.Image = (Image)nlrm.GetObject("Paula");
			namePhrase = lrm.GetString("Name");
			modifiedDatePhrase = lrm.GetString("ModifiedDate");
			noErrorMessage = errorLabel.Text;
			languageComboBox.Items.AddRange(GetLanguageComboBoxItems(lrm));
			languageComboBox.SelectedIndex = 0;

            summaryBindingNavigator.BindingSource = summaryBindingSource;
        }

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
			System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
			System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
			System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
			System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
			this.mainTabControl = new System.Windows.Forms.TabControl();
			this.mainTabPage = new System.Windows.Forms.TabPage();
			this.newsLabel = new System.Windows.Forms.Label();
			this.newsPictureBox = new System.Windows.Forms.PictureBox();
			this.introLabel = new System.Windows.Forms.Label();
			this.headlineLabel = new System.Windows.Forms.Label();
			this.unassignedOpenPositionsButton = new System.Windows.Forms.Button();
			this.pendingInterviewsButton = new System.Windows.Forms.Button();
			this.assignedOpenPositionsButton = new System.Windows.Forms.Button();
			this.resumeTabPage = new System.Windows.Forms.TabPage();
			this.summaryDataGridView = new System.Windows.Forms.DataGridView();
			this.summaryBindingNavigator = new System.Windows.Forms.BindingNavigator(this.components);
			this.dataNavigatorCountItem = new System.Windows.Forms.ToolStripLabel();
			this.dataNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton();
			this.dataNavigatorMovePreviousItem = new System.Windows.Forms.ToolStripButton();
			this.dataNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator();
			this.dataNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox();
			this.dataNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator();
			this.dataNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton();
			this.dataNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton();
			this.dataNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator();
			this.ToCalendarButton = new System.Windows.Forms.Button();
			this.FromCalendarButton = new System.Windows.Forms.Button();
			this.languageComboBox = new System.Windows.Forms.ComboBox();
			this.errorLabel = new System.Windows.Forms.Label();
			this.searchButton = new System.Windows.Forms.Button();
			this.searchModeComboBox = new System.Windows.Forms.ComboBox();
			this.textSearchTextBox = new System.Windows.Forms.TextBox();
			this.dateToTextBox = new System.Windows.Forms.TextBox();
			this.dateFromTextBox = new System.Windows.Forms.TextBox();
			this.candidateNameTextBox = new System.Windows.Forms.TextBox();
			this.textSearchLabel = new System.Windows.Forms.Label();
			this.dataRangeLabel = new System.Windows.Forms.Label();
			this.candidateNameLabel = new System.Windows.Forms.Label();
			this.resumeDetailsWebBrowser = new System.Windows.Forms.WebBrowser();
			this.summaryDataGridView2 = new System.Windows.Forms.DataGridView();
			this.panel1 = new System.Windows.Forms.Panel();
			this.pictureBox2 = new System.Windows.Forms.PictureBox();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.fileMenuItem = new System.Windows.Forms.MenuItem();
			this.exitMenuItem = new System.Windows.Forms.MenuItem();
			this.editMenuItem = new System.Windows.Forms.MenuItem();
			this.viewMenuItem = new System.Windows.Forms.MenuItem();
			this.helpMenuItem = new System.Windows.Forms.MenuItem();
			this.fileMenuItem1 = new System.Windows.Forms.MenuItem();
			this.newMenuItem = new System.Windows.Forms.MenuItem();
			this.openMenuItem = new System.Windows.Forms.MenuItem();
			this.separatorMenuItem = new System.Windows.Forms.MenuItem();
			this.saveMenuItem = new System.Windows.Forms.MenuItem();
			this.saveAsMenuItem = new System.Windows.Forms.MenuItem();
			this.separatorMenuItem1 = new System.Windows.Forms.MenuItem();
			this.printMenuItem = new System.Windows.Forms.MenuItem();
			this.printPreviewMenuItem = new System.Windows.Forms.MenuItem();
			this.separatorMenuItem2 = new System.Windows.Forms.MenuItem();
			this.exitMenuItem1 = new System.Windows.Forms.MenuItem();
			this.editMenuItem1 = new System.Windows.Forms.MenuItem();
			this.undoMenuItem = new System.Windows.Forms.MenuItem();
			this.redoMenuItem = new System.Windows.Forms.MenuItem();
			this.separatorMenuItem3 = new System.Windows.Forms.MenuItem();
			this.cutMenuItem = new System.Windows.Forms.MenuItem();
			this.copyMenuItem = new System.Windows.Forms.MenuItem();
			this.pasteMenuItem = new System.Windows.Forms.MenuItem();
			this.separatorMenuItem4 = new System.Windows.Forms.MenuItem();
			this.selectAllMenuItem = new System.Windows.Forms.MenuItem();
			this.helpMenuItem1 = new System.Windows.Forms.MenuItem();
			this.contentsMenuItem = new System.Windows.Forms.MenuItem();
			this.indexMenuItem = new System.Windows.Forms.MenuItem();
			this.searchMenuItem = new System.Windows.Forms.MenuItem();
			this.separatorMenuItem5 = new System.Windows.Forms.MenuItem();
			this.aboutMenuItem = new System.Windows.Forms.MenuItem();
			this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
			this.standardMainMenu = new System.Windows.Forms.MainMenu(this.components);
			this.summaryBindingSource = new System.Windows.Forms.BindingSource(this.components);
			this.mainTabControl.SuspendLayout();
			this.mainTabPage.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.newsPictureBox)).BeginInit();
			this.resumeTabPage.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.summaryDataGridView)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.summaryBindingNavigator)).BeginInit();
			this.summaryBindingNavigator.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.summaryDataGridView2)).BeginInit();
			this.panel1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.summaryBindingSource)).BeginInit();
			this.SuspendLayout();
			// 
			// mainTabControl
			// 
			this.mainTabControl.Controls.Add(this.mainTabPage);
			this.mainTabControl.Controls.Add(this.resumeTabPage);
			resources.ApplyResources(this.mainTabControl, "mainTabControl");
			this.mainTabControl.Name = "mainTabControl";
			this.mainTabControl.SelectedIndex = 0;
			// 
			// mainTabPage
			// 
			this.mainTabPage.Controls.Add(this.newsLabel);
			this.mainTabPage.Controls.Add(this.newsPictureBox);
			this.mainTabPage.Controls.Add(this.introLabel);
			this.mainTabPage.Controls.Add(this.headlineLabel);
			this.mainTabPage.Controls.Add(this.unassignedOpenPositionsButton);
			this.mainTabPage.Controls.Add(this.pendingInterviewsButton);
			this.mainTabPage.Controls.Add(this.assignedOpenPositionsButton);
			resources.ApplyResources(this.mainTabPage, "mainTabPage");
			this.mainTabPage.Name = "mainTabPage";
			this.mainTabPage.Padding = new System.Windows.Forms.Padding(3);
			// 
			// newsLabel
			// 
			resources.ApplyResources(this.newsLabel, "newsLabel");
			this.newsLabel.Name = "newsLabel";
			// 
			// newsPictureBox
			// 
			resources.ApplyResources(this.newsPictureBox, "newsPictureBox");
			this.newsPictureBox.Name = "newsPictureBox";
			this.newsPictureBox.TabStop = false;
			// 
			// introLabel
			// 
			resources.ApplyResources(this.introLabel, "introLabel");
			this.introLabel.ForeColor = System.Drawing.Color.RoyalBlue;
			this.introLabel.Name = "introLabel";
			// 
			// headlineLabel
			// 
			this.headlineLabel.BackColor = System.Drawing.Color.Firebrick;
			resources.ApplyResources(this.headlineLabel, "headlineLabel");
			this.headlineLabel.Name = "headlineLabel";
			// 
			// unassignedOpenPositionsButton
			// 
			resources.ApplyResources(this.unassignedOpenPositionsButton, "unassignedOpenPositionsButton");
			this.unassignedOpenPositionsButton.Name = "unassignedOpenPositionsButton";
			// 
			// pendingInterviewsButton
			// 
			resources.ApplyResources(this.pendingInterviewsButton, "pendingInterviewsButton");
			this.pendingInterviewsButton.Name = "pendingInterviewsButton";
			// 
			// assignedOpenPositionsButton
			// 
			resources.ApplyResources(this.assignedOpenPositionsButton, "assignedOpenPositionsButton");
			this.assignedOpenPositionsButton.Name = "assignedOpenPositionsButton";
			// 
			// resumeTabPage
			// 
			this.resumeTabPage.Controls.Add(this.summaryDataGridView);
			this.resumeTabPage.Controls.Add(this.summaryBindingNavigator);
			this.resumeTabPage.Controls.Add(this.ToCalendarButton);
			this.resumeTabPage.Controls.Add(this.FromCalendarButton);
			this.resumeTabPage.Controls.Add(this.languageComboBox);
			this.resumeTabPage.Controls.Add(this.errorLabel);
			this.resumeTabPage.Controls.Add(this.searchButton);
			this.resumeTabPage.Controls.Add(this.searchModeComboBox);
			this.resumeTabPage.Controls.Add(this.textSearchTextBox);
			this.resumeTabPage.Controls.Add(this.dateToTextBox);
			this.resumeTabPage.Controls.Add(this.dateFromTextBox);
			this.resumeTabPage.Controls.Add(this.candidateNameTextBox);
			this.resumeTabPage.Controls.Add(this.textSearchLabel);
			this.resumeTabPage.Controls.Add(this.dataRangeLabel);
			this.resumeTabPage.Controls.Add(this.candidateNameLabel);
			this.resumeTabPage.Controls.Add(this.resumeDetailsWebBrowser);
			resources.ApplyResources(this.resumeTabPage, "resumeTabPage");
			this.resumeTabPage.Name = "resumeTabPage";
			this.resumeTabPage.Padding = new System.Windows.Forms.Padding(3);
			// 
			// summaryDataGridView
			// 
			this.summaryDataGridView.AllowUserToAddRows = false;
			this.summaryDataGridView.AllowUserToDeleteRows = false;
			this.summaryDataGridView.BackgroundColor = System.Drawing.Color.LightGray;
			this.summaryDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
			dataGridViewCellStyle1.BackColor = System.Drawing.Color.MidnightBlue;
			dataGridViewCellStyle1.Font = new System.Drawing.Font("Tahoma", 8F);
			dataGridViewCellStyle1.ForeColor = System.Drawing.Color.WhiteSmoke;
			this.summaryDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
			dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle2.BackColor = System.Drawing.Color.WhiteSmoke;
			dataGridViewCellStyle2.Font = new System.Drawing.Font("Tahoma", 8F);
			dataGridViewCellStyle2.ForeColor = System.Drawing.Color.MidnightBlue;
			dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
			dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
			dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
			this.summaryDataGridView.DefaultCellStyle = dataGridViewCellStyle2;
			resources.ApplyResources(this.summaryDataGridView, "summaryDataGridView");
			this.summaryDataGridView.GridColor = System.Drawing.Color.Gainsboro;
			this.summaryDataGridView.Name = "summaryDataGridView";
			this.summaryDataGridView.ReadOnly = true;
			this.summaryDataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle1;
			this.summaryDataGridView.Click += new System.EventHandler(this.summaryDataGridView_Click);
			// 
			// summaryBindingNavigator
			// 
			this.summaryBindingNavigator.AddNewItem = null;
			this.summaryBindingNavigator.CountItem = this.dataNavigatorCountItem;
			this.summaryBindingNavigator.CountItemFormat = "of {0}";
			this.summaryBindingNavigator.DeleteItem = null;
			resources.ApplyResources(this.summaryBindingNavigator, "summaryBindingNavigator");
			this.summaryBindingNavigator.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.dataNavigatorMoveFirstItem,
            this.dataNavigatorMovePreviousItem,
            this.dataNavigatorSeparator,
            this.dataNavigatorPositionItem,
            this.dataNavigatorCountItem,
            this.dataNavigatorSeparator1,
            this.dataNavigatorMoveNextItem,
            this.dataNavigatorMoveLastItem,
            this.dataNavigatorSeparator2});
			this.summaryBindingNavigator.MoveFirstItem = this.dataNavigatorMoveFirstItem;
			this.summaryBindingNavigator.MoveLastItem = this.dataNavigatorMoveLastItem;
			this.summaryBindingNavigator.MoveNextItem = this.dataNavigatorMoveNextItem;
			this.summaryBindingNavigator.MovePreviousItem = this.dataNavigatorMovePreviousItem;
			this.summaryBindingNavigator.Name = "summaryBindingNavigator";
			this.summaryBindingNavigator.PositionItem = this.dataNavigatorPositionItem;
			// 
			// dataNavigatorCountItem
			// 
			this.dataNavigatorCountItem.Name = "dataNavigatorCountItem";
			resources.ApplyResources(this.dataNavigatorCountItem, "dataNavigatorCountItem");
			// 
			// dataNavigatorMoveFirstItem
			// 
			this.dataNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			resources.ApplyResources(this.dataNavigatorMoveFirstItem, "dataNavigatorMoveFirstItem");
			this.dataNavigatorMoveFirstItem.Name = "dataNavigatorMoveFirstItem";
			// 
			// dataNavigatorMovePreviousItem
			// 
			this.dataNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			resources.ApplyResources(this.dataNavigatorMovePreviousItem, "dataNavigatorMovePreviousItem");
			this.dataNavigatorMovePreviousItem.Name = "dataNavigatorMovePreviousItem";
			// 
			// dataNavigatorSeparator
			// 
			this.dataNavigatorSeparator.Name = "dataNavigatorSeparator";
			// 
			// dataNavigatorPositionItem
			// 
			this.dataNavigatorPositionItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText;
			this.dataNavigatorPositionItem.Name = "dataNavigatorPositionItem";
			resources.ApplyResources(this.dataNavigatorPositionItem, "dataNavigatorPositionItem");
			// 
			// dataNavigatorSeparator1
			// 
			this.dataNavigatorSeparator1.Name = "dataNavigatorSeparator1";
			// 
			// dataNavigatorMoveNextItem
			// 
			this.dataNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			resources.ApplyResources(this.dataNavigatorMoveNextItem, "dataNavigatorMoveNextItem");
			this.dataNavigatorMoveNextItem.Name = "dataNavigatorMoveNextItem";
			// 
			// dataNavigatorMoveLastItem
			// 
			this.dataNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			resources.ApplyResources(this.dataNavigatorMoveLastItem, "dataNavigatorMoveLastItem");
			this.dataNavigatorMoveLastItem.Name = "dataNavigatorMoveLastItem";
			// 
			// dataNavigatorSeparator2
			// 
			this.dataNavigatorSeparator2.Name = "dataNavigatorSeparator2";
			// 
			// ToCalendarButton
			// 
			this.ToCalendarButton.Image = Microsoft.Samples.SqlServer.NonLocalizedResources.calendar_bmp;
			resources.ApplyResources(this.ToCalendarButton, "ToCalendarButton");
			this.ToCalendarButton.Name = "ToCalendarButton";
			this.ToCalendarButton.Click += new System.EventHandler(this.ToCalendarButton_Click);
			// 
			// FromCalendarButton
			// 
			this.FromCalendarButton.Image = Microsoft.Samples.SqlServer.NonLocalizedResources.calendar_bmp;
			resources.ApplyResources(this.FromCalendarButton, "FromCalendarButton");
			this.FromCalendarButton.Name = "FromCalendarButton";
			this.FromCalendarButton.Click += new System.EventHandler(this.FromCalendarButton_Click);
			// 
			// languageComboBox
			// 
			this.languageComboBox.DisplayMember = "Name";
			this.languageComboBox.FormattingEnabled = true;
			resources.ApplyResources(this.languageComboBox, "languageComboBox");
			this.languageComboBox.Name = "languageComboBox";
			this.languageComboBox.ValueMember = "Lcid";
			// 
			// errorLabel
			// 
			resources.ApplyResources(this.errorLabel, "errorLabel");
			this.errorLabel.Name = "errorLabel";
			// 
			// searchButton
			// 
			resources.ApplyResources(this.searchButton, "searchButton");
			this.searchButton.Name = "searchButton";
			this.searchButton.Click += new System.EventHandler(this.searchButton_Click);
			// 
			// searchModeComboBox
			// 
			this.searchModeComboBox.FormattingEnabled = true;
			resources.ApplyResources(this.searchModeComboBox, "searchModeComboBox");
			this.searchModeComboBox.Name = "searchModeComboBox";
			// 
			// textSearchTextBox
			// 
			resources.ApplyResources(this.textSearchTextBox, "textSearchTextBox");
			this.textSearchTextBox.Name = "textSearchTextBox";
			// 
			// dateToTextBox
			// 
			resources.ApplyResources(this.dateToTextBox, "dateToTextBox");
			this.dateToTextBox.Name = "dateToTextBox";
			// 
			// dateFromTextBox
			// 
			resources.ApplyResources(this.dateFromTextBox, "dateFromTextBox");
			this.dateFromTextBox.Name = "dateFromTextBox";
			// 
			// candidateNameTextBox
			// 
			resources.ApplyResources(this.candidateNameTextBox, "candidateNameTextBox");
			this.candidateNameTextBox.Name = "candidateNameTextBox";
			// 
			// textSearchLabel
			// 
			resources.ApplyResources(this.textSearchLabel, "textSearchLabel");
			this.textSearchLabel.Name = "textSearchLabel";
			// 
			// dataRangeLabel
			// 
			resources.ApplyResources(this.dataRangeLabel, "dataRangeLabel");
			this.dataRangeLabel.Name = "dataRangeLabel";
			// 
			// candidateNameLabel
			// 
			resources.ApplyResources(this.candidateNameLabel, "candidateNameLabel");
			this.candidateNameLabel.Name = "candidateNameLabel";
			// 
			// resumeDetailsWebBrowser
			// 
			resources.ApplyResources(this.resumeDetailsWebBrowser, "resumeDetailsWebBrowser");
			this.resumeDetailsWebBrowser.Name = "resumeDetailsWebBrowser";
			// 
			// summaryDataGridView2
			// 
			this.summaryDataGridView2.AllowUserToAddRows = false;
			this.summaryDataGridView2.AllowUserToDeleteRows = false;
			this.summaryDataGridView2.BackgroundColor = System.Drawing.Color.Silver;
			this.summaryDataGridView2.BorderStyle = System.Windows.Forms.BorderStyle.None;
			dataGridViewCellStyle3.BackColor = System.Drawing.Color.MidnightBlue;
			dataGridViewCellStyle3.Font = new System.Drawing.Font("Tahoma", 8F);
			dataGridViewCellStyle3.ForeColor = System.Drawing.Color.White;
			this.summaryDataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3;
			resources.ApplyResources(this.summaryDataGridView2, "summaryDataGridView2");
			dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle4.BackColor = System.Drawing.Color.Gainsboro;
			dataGridViewCellStyle4.Font = new System.Drawing.Font("Tahoma", 8F);
			dataGridViewCellStyle4.ForeColor = System.Drawing.Color.Black;
			dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.ActiveCaption;
			dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
			this.summaryDataGridView2.DefaultCellStyle = dataGridViewCellStyle4;
			this.summaryDataGridView2.GridColor = System.Drawing.Color.DimGray;
			this.summaryDataGridView2.Name = "summaryDataGridView2";
			this.summaryDataGridView2.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
			// 
			// panel1
			// 
			this.panel1.BackColor = System.Drawing.Color.DarkCyan;
			this.panel1.BackgroundImage = Microsoft.Samples.SqlServer.NonLocalizedResources.grid_background_gif;
			this.panel1.Controls.Add(this.pictureBox2);
			this.panel1.Controls.Add(this.pictureBox1);
			resources.ApplyResources(this.panel1, "panel1");
			this.panel1.Name = "panel1";
			// 
			// pictureBox2
			// 
			this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
			this.pictureBox2.Image = Microsoft.Samples.SqlServer.NonLocalizedResources.logo_jpg;
			resources.ApplyResources(this.pictureBox2, "pictureBox2");
			this.pictureBox2.Name = "pictureBox2";
			this.pictureBox2.TabStop = false;
			// 
			// pictureBox1
			// 
			this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
			this.pictureBox1.Image = Microsoft.Samples.SqlServer.NonLocalizedResources.CompanyName_gif;
			resources.ApplyResources(this.pictureBox1, "pictureBox1");
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.TabStop = false;
			// 
			// fileMenuItem
			// 
			this.fileMenuItem.Index = 0;
			this.fileMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.exitMenuItem});
			resources.ApplyResources(this.fileMenuItem, "fileMenuItem");
			// 
			// exitMenuItem
			// 
			this.exitMenuItem.Index = 0;
			resources.ApplyResources(this.exitMenuItem, "exitMenuItem");
			this.exitMenuItem.Click += new System.EventHandler(this.exitMenuItem_Click);
			// 
			// editMenuItem
			// 
			this.editMenuItem.Index = 1;
			resources.ApplyResources(this.editMenuItem, "editMenuItem");
			// 
			// viewMenuItem
			// 
			this.viewMenuItem.Index = 2;
			resources.ApplyResources(this.viewMenuItem, "viewMenuItem");
			// 
			// helpMenuItem
			// 
			this.helpMenuItem.Index = 3;
			resources.ApplyResources(this.helpMenuItem, "helpMenuItem");
			// 
			// fileMenuItem1
			// 
			this.fileMenuItem1.Index = 0;
			this.fileMenuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.newMenuItem,
            this.openMenuItem,
            this.separatorMenuItem,
            this.saveMenuItem,
            this.saveAsMenuItem,
            this.separatorMenuItem1,
            this.printMenuItem,
            this.printPreviewMenuItem,
            this.separatorMenuItem2,
            this.exitMenuItem1});
			resources.ApplyResources(this.fileMenuItem1, "fileMenuItem1");
			// 
			// newMenuItem
			// 
			resources.ApplyResources(this.newMenuItem, "newMenuItem");
			this.newMenuItem.Index = 0;
			// 
			// openMenuItem
			// 
			resources.ApplyResources(this.openMenuItem, "openMenuItem");
			this.openMenuItem.Index = 1;
			// 
			// separatorMenuItem
			// 
			this.separatorMenuItem.Index = 2;
			resources.ApplyResources(this.separatorMenuItem, "separatorMenuItem");
			// 
			// saveMenuItem
			// 
			resources.ApplyResources(this.saveMenuItem, "saveMenuItem");
			this.saveMenuItem.Index = 3;
			// 
			// saveAsMenuItem
			// 
			resources.ApplyResources(this.saveAsMenuItem, "saveAsMenuItem");
			this.saveAsMenuItem.Index = 4;
			// 
			// separatorMenuItem1
			// 
			this.separatorMenuItem1.Index = 5;
			resources.ApplyResources(this.separatorMenuItem1, "separatorMenuItem1");
			// 
			// printMenuItem
			// 
			resources.ApplyResources(this.printMenuItem, "printMenuItem");
			this.printMenuItem.Index = 6;
			// 
			// printPreviewMenuItem
			// 
			resources.ApplyResources(this.printPreviewMenuItem, "printPreviewMenuItem");
			this.printPreviewMenuItem.Index = 7;
			// 
			// separatorMenuItem2
			// 
			this.separatorMenuItem2.Index = 8;
			resources.ApplyResources(this.separatorMenuItem2, "separatorMenuItem2");
			// 
			// exitMenuItem1
			// 
			this.exitMenuItem1.Index = 9;
			resources.ApplyResources(this.exitMenuItem1, "exitMenuItem1");
			this.exitMenuItem1.Click += new System.EventHandler(this.exitMenuItem1_Click);
			// 
			// editMenuItem1
			// 
			this.editMenuItem1.Index = 1;
			this.editMenuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.undoMenuItem,
            this.redoMenuItem,
            this.separatorMenuItem3,
            this.cutMenuItem,
            this.copyMenuItem,
            this.pasteMenuItem,
            this.separatorMenuItem4,
            this.selectAllMenuItem});
			resources.ApplyResources(this.editMenuItem1, "editMenuItem1");
			// 
			// undoMenuItem
			// 
			resources.ApplyResources(this.undoMenuItem, "undoMenuItem");
			this.undoMenuItem.Index = 0;
			// 
			// redoMenuItem
			// 
			resources.ApplyResources(this.redoMenuItem, "redoMenuItem");
			this.redoMenuItem.Index = 1;
			// 
			// separatorMenuItem3
			// 
			this.separatorMenuItem3.Index = 2;
			resources.ApplyResources(this.separatorMenuItem3, "separatorMenuItem3");
			// 
			// cutMenuItem
			// 
			resources.ApplyResources(this.cutMenuItem, "cutMenuItem");
			this.cutMenuItem.Index = 3;
			// 
			// copyMenuItem
			// 
			resources.ApplyResources(this.copyMenuItem, "copyMenuItem");
			this.copyMenuItem.Index = 4;
			// 
			// pasteMenuItem
			// 
			resources.ApplyResources(this.pasteMenuItem, "pasteMenuItem");
			this.pasteMenuItem.Index = 5;
			// 
			// separatorMenuItem4
			// 
			this.separatorMenuItem4.Index = 6;
			resources.ApplyResources(this.separatorMenuItem4, "separatorMenuItem4");
			// 
			// selectAllMenuItem
			// 
			resources.ApplyResources(this.selectAllMenuItem, "selectAllMenuItem");
			this.selectAllMenuItem.Index = 7;
			// 
			// helpMenuItem1
			// 
			this.helpMenuItem1.Index = 2;
			this.helpMenuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.contentsMenuItem,
            this.indexMenuItem,
            this.searchMenuItem,
            this.separatorMenuItem5,
            this.aboutMenuItem});
			resources.ApplyResources(this.helpMenuItem1, "helpMenuItem1");
			// 
			// contentsMenuItem
			// 
			resources.ApplyResources(this.contentsMenuItem, "contentsMenuItem");
			this.contentsMenuItem.Index = 0;
			// 
			// indexMenuItem
			// 
			resources.ApplyResources(this.indexMenuItem, "indexMenuItem");
			this.indexMenuItem.Index = 1;
			// 
			// searchMenuItem
			// 
			resources.ApplyResources(this.searchMenuItem, "searchMenuItem");
			this.searchMenuItem.Index = 2;
			// 
			// separatorMenuItem5
			// 
			this.separatorMenuItem5.Index = 3;
			resources.ApplyResources(this.separatorMenuItem5, "separatorMenuItem5");
			// 
			// aboutMenuItem
			// 
			this.aboutMenuItem.Index = 4;
			resources.ApplyResources(this.aboutMenuItem, "aboutMenuItem");
			this.aboutMenuItem.Click += new System.EventHandler(this.aboutMenuItem_Click);
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.fileMenuItem,
            this.editMenuItem,
            this.viewMenuItem,
            this.helpMenuItem});
			// 
			// standardMainMenu
			// 
			this.standardMainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.fileMenuItem1,
            this.editMenuItem1,
            this.helpMenuItem1});
			// 
			// summaryBindingSource
			// 
			this.summaryBindingSource.AllowNew = false;
			// 
			// MainForm
			// 
			resources.ApplyResources(this, "$this");
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.mainTabControl);
			this.Menu = this.standardMainMenu;
			this.Name = "MainForm";
			this.mainTabControl.ResumeLayout(false);
			this.mainTabPage.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.newsPictureBox)).EndInit();
			this.resumeTabPage.ResumeLayout(false);
			this.resumeTabPage.PerformLayout();
			((System.ComponentModel.ISupportInitialize)(this.summaryDataGridView)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.summaryBindingNavigator)).EndInit();
			this.summaryBindingNavigator.ResumeLayout(false);
			this.summaryBindingNavigator.PerformLayout();
			((System.ComponentModel.ISupportInitialize)(this.summaryDataGridView2)).EndInit();
			this.panel1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.summaryBindingSource)).EndInit();
			this.ResumeLayout(false);

        }
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()
		{
			Application.EnableVisualStyles();
			Application.Run(new MainForm());
		}

		/// <summary>
		///		When the user select the Exit menu item, terminate the application.
		/// </summary>
		/// <param name="sender">Who sent the event</param>
		/// <param name="e">What additional information is known</param>
		private void exitMenuItem_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		/// <summary>
		///		When the user presess the search button, this handler is
		///		invoked.  The search criteria are extracted from the controls,
		///		and the HRWebService is invoked in order to enumerate
		///		the candidates which match the specified search criteria.
		/// </summary>
		/// <param name="sender">Who sent the event</param>
		/// <param name="e">What additional information is known</param>
		private void searchButton_Click(object sender, System.EventArgs e)
		{
			using (Service webService = new Service())
			{
				// Use the credentials of the user currently logged into the client machine.
				webService.Credentials = CredentialCache.DefaultCredentials;

				// Invoke the SearchResumes web method of the HRWebService,
				// pulling the method arguments from the controls on the page.
				Cursor previousCursor = Cursor.Current;

				try
				{
					Cursor.Current = Cursors.WaitCursor;

					DataSet summary = webService.SearchResumes(
						candidateNameTextBox.Text,
						(dateFromTextBox.Text == String.Empty) ?
						DateTime.MinValue :
						DateTime.Parse(dateFromTextBox.Text,
									   CultureInfo.CurrentCulture),
						(dateToTextBox.Text == String.Empty) ?
						DateTime.MaxValue :
						DateTime.Parse(dateToTextBox.Text,
									   CultureInfo.CurrentCulture),
						textSearchTextBox.Text,
						(searchModeComboBox.Text == allOfThesePhrase),
						((LanguageItem)(languageComboBox.SelectedItem)).Lcid);
					DataTable errorTable = summary.Tables["Errors"];

					if (errorTable != null && errorTable.Rows.Count > 0)
					{
						DataRow dr = errorTable.Rows[0];

						throw new RemoteException((Int32)dr["ErrorCode"],
												  (String)dr["ErrorMessage"]);
					}

                    summaryDataGridView.ClearSelection();

					// Databind to the new data set.
					if (summary.Tables.Count > 0)
					{
						DataTable summaryTable = summary.Tables[0];

						// Web services seems to convert single quotes into
						// an entity.  We reverse this process before
						// names are displayed.
						if (summaryTable.Columns["Name"] != null)
						{
							foreach (DataRow dr in summaryTable.Rows)
							{
								dr["Name"] = ((String)dr["Name"]).Replace(
									"&apos;", "'");
							}

							summaryTable.Columns["Name"].ColumnName =
							namePhrase;
						}

						if (summaryTable.Columns["ModifiedDate"] != null)
							summaryTable.Columns["ModifiedDate"].ColumnName =
							modifiedDatePhrase;

                        summaryBindingSource.DataSource = summaryTable;
                        summaryDataGridView.DataSource = summaryBindingSource;

                        // Keep the DataSet handy for when we need to interpret indicies
						// from RowEntry events.
                        summaryBindingNavigator.Tag = summary.Tables[0];
						if (summaryDataGridView.Columns["JobCandidateID"] !=
							null)
						{
							summaryDataGridView.Columns["JobCandidateID"].
							Visible = false;
						}

						DataGridViewColumn nameColumn = summaryDataGridView.Columns[namePhrase];
						if (nameColumn != null)
						{
							nameColumn.MinimumWidth = 200;
						}

						DataGridViewColumn modifiedDateColumn = summaryDataGridView.Columns[modifiedDatePhrase];

						if (modifiedDateColumn != null)
						{
							modifiedDateColumn.MinimumWidth = 150;
						}
					}

					// Empty out the web browser control so it doesn't contain a stale
					// resume.
					resumeDetailsWebBrowser.Navigate(new Uri("about:blank"));
					errorLabel.Text = noErrorMessage;


                } 
				catch (System.Exception se)
				{
					ResourceManager rm = new ResourceManager(
						"Microsoft.Samples.SqlServer.LocalizedResources",
						Assembly.GetExecutingAssembly());
					RemoteException remoteError = se as RemoteException;

                    if (remoteError != null && remoteError.ErrorCode != -1)
                    {
                        String errorMessage = rm.GetString("Error" +
                                                           remoteError.
                                                           ErrorCode);

                        if (errorMessage != null)
                            errorLabel.Text = errorMessage;
                        else
                            errorLabel.Text = String.Format(CultureInfo.CurrentCulture, "{0}\n{1}",
                                                            rm.GetString("ErrorUnknownSql"),
                                                            remoteError.
                                                            ErrorMessage);
                    }
                    else
                    {
                        errorLabel.Text = String.Format(CultureInfo.CurrentCulture,
                            "{0}\n{1}",
                                                        rm.GetString("ErrorUnknown"),
                                                        se.ToString());
                    }

                } 
				finally
				{
					Cursor.Current = previousCursor;
				}
			}
		}

		// The handler called when a row of the data grid is clicked.  Display
		// the resume associated with the selected row using the web browser 
		// control.
		private void summaryDataGridView_RowEnter(object sender,
												  DataGridViewCellEventArgs e)
		{
			// If there is data backing the control, and the row index clicked
			// is within range...
			if (summaryBindingNavigator.Tag != null  &&
                (((DataTable)summaryBindingNavigator.Tag).Rows.Count > e.RowIndex))
            {
				// Invoke the HRWebService to fetch the contents of the 
				// appropriate resume.
				using (Service webService = new Service())
				{
					webService.Credentials = CredentialCache.DefaultCredentials;

					//TODO: Switch back to using DocumentText property some day.
					//This currently uses a temporarily file due to a bug in the 
					//WebBrowser control,

                    using (FileStream fs = new FileStream(tempFileName,
                                                          FileMode.Create))
                    {
                        using (StreamWriter sw = new StreamWriter(fs, Encoding.Unicode))
                        {
                            //Transform the XML resume into HTML
                            //and out the results to a temporary file.                            
                            sw.Write(TransformResume(webService.ResumeContents(
                                (int)((DataTable)summaryBindingNavigator.Tag).Rows[e.RowIndex]["JobCandidateID"])));
                            sw.Flush();
                        }
                    }

                    //Navigate the web browser control to this temporary file
                    resumeDetailsWebBrowser.Navigate(
                        new Uri(string.Format(CultureInfo.InvariantCulture,
                        "file:///{0}", tempFileName)));
                }
			}
		}

		/// <summary>
		///		Given an XML based resume transform that resume into HTML.
		/// </summary>
		/// <param name="resumeXML">A string containing the XML content of the resume</param>
		/// <returns>A string containing the resulting HTML</returns>
		private string TransformResume(string resumeXML)
		{
            using (StringWriter resultStringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                using (XmlTextWriter resultXmlWriter = new XmlTextWriter(resultStringWriter))
                {
                    //Place the resume into an object suitable for transformation.
                    using (StringReader sr = new StringReader(resumeXML))
                    {
                        using (XmlReader xtr = XmlReader.Create(sr))
                        {
                            XPathDocument resumeDoc = new XPathDocument(xtr);

                            XslCompiledTransform transform = new XslCompiledTransform();
                            //Initialize the object which performs the translation from XML to HTML.
                            using (StringReader stylesheetStringReader = new StringReader(stylesheet))
                            {
                                using (XmlReader stylesheetXmlReader = XmlReader.Create(stylesheetStringReader))
                                {
                                    transform.Load(stylesheetXmlReader);
                                    //Invoke the translation
                                    transform.Transform(resumeDoc, new XsltArgumentList(), resultXmlWriter);
                                    resultXmlWriter.Flush();
                                    //Return the results of the translation back to the caller.
                                    return resultStringWriter.ToString();
                                }
                            }
                        }
                    }
                }
            }
        }

		private void aboutMenuItem_Click(object sender, System.EventArgs e)
		{
			About aboutDialog = new About();

			aboutDialog.ShowDialog();
		}

		private void exitMenuItem1_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		private LanguageItem[] GetLanguageComboBoxItems(ResourceManager rm)
		{
			using (Service webService = new Service())
			{
				webService.Credentials = CredentialCache.DefaultCredentials;

				int[] lcids = webService.FullTextLanguages();
				int lcidCount = lcids.Length + 1;

				//Consider using generics
				ArrayList resultList = new ArrayList(lcidCount);
				CultureInfo defaultCulture = CultureInfo.CreateSpecificCulture("en-US");
				if (Array.IndexOf(lcids, CultureInfo.CurrentCulture.LCID) != -1)
					defaultCulture = CultureInfo.CurrentCulture;

				resultList.Add(new LanguageItem(defaultCulture.LCID,
												rm.GetString("LanguageMessage")));

				foreach (CultureInfo c in CultureInfo.GetCultures(CultureTypes.
																  SpecificCultures))
				{
					if (Array.IndexOf(lcids, c.LCID) != -1)
					{
						resultList.Add(new LanguageItem(c.LCID, c.DisplayName));
						if (resultList.Count == lcidCount) break;
					}
				}



				return (LanguageItem[])resultList.ToArray(Type.GetType("Microsoft.Samples.SqlServer.LanguageItem"));
			}
		}

		private void FromCalendarButton_Click(object sender, System.EventArgs e)
		{
			CalendarForm calendar = new CalendarForm();
			if (calendar.ShowDialog() == DialogResult.OK)
			{
				SelectionRange sr = calendar.GetDateRange;
				dateFromTextBox.Text = sr.Start.ToShortDateString();

				if (sr.Start != sr.End)
					dateToTextBox.Text = sr.End.ToShortDateString();
			}
		}

		private void ToCalendarButton_Click(object sender, System.EventArgs e)
		{
			CalendarForm calendar = new CalendarForm();

			if (calendar.ShowDialog() == DialogResult.OK)
			{
				SelectionRange sr = calendar.GetDateRange;

				dateToTextBox.Text = sr.End.ToShortDateString();
				if (sr.Start != sr.End)
					dateFromTextBox.Text = sr.Start.ToShortDateString();
			}
		}

        private void summaryDataGridView_Click(object sender, EventArgs e)
        {
        
        }
		
		} //Class MainForm

    [Serializable]
    public class RemoteException : ApplicationException
	{
		private int errorCode = -1;
		private String errorMessage = "";

		public int ErrorCode
		{
			get
			{
				return errorCode;
			}
		}

		public String ErrorMessage
		{
			get
			{
				return errorMessage;
			}
		}

        public RemoteException() : base("A remote exception has occurred.")
        {
        }

        public RemoteException(string message): base(message)
        {
        }

        public RemoteException(string message, Exception innerException): base (message, innerException)
        {
        }

        protected RemoteException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }

        public RemoteException(int errorCode, String errorMessage)
		{
			this.errorCode = errorCode;
			this.errorMessage = errorMessage;
		}
	}

	public class LanguageItem
	{
		private int lcid;
		private String name;

		public int Lcid
		{
			get
			{
				return this.lcid;
			}
		}

		public String Name
		{
			get
			{
				return this.name;
			}
		}

		public LanguageItem(int lcid, String name)
		{
			this.lcid = lcid;
			this.name = name;
		}
	}

}
